<?php
class Helper_User {

    public static function downloadAvatar($from, $width) {
            $registry = Registry::getInstance();
            $registry->load->library("SimpleImage");
            $image = new SimpleImage();
            if(!$image->load($from)) return false;
            $image->resizeToWidth($width);
            $avatar_name = generateCode(16);
            $path = DIR_IMAGES.'avatars/'.$avatar_name.'.png';
            $image->save($path);
            return $path;
    }
}
?>
